﻿using EasyAbp.Abp.Aliyun.Common.Configurations;
using EasyAbp.Abp.Aliyun.Sms;
using EasyAbp.Abp.PhoneNumberLogin.Provider.Aliyun.Localization;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Volo.Abp.Localization;
using Volo.Abp.Localization.ExceptionHandling;
using Volo.Abp.Modularity;
using Volo.Abp.Sms;
using Volo.Abp.Validation.Localization;
using Volo.Abp.VirtualFileSystem;
namespace EasyAbp.Abp.PhoneNumberLogin.Provider.Aliyun
{

    [DependsOn(
        typeof(AbpPhoneNumberLoginApplicationModule),
        typeof(AbpAliyunSmsModule)
    )]
    public class AbpPhoneNumberLoginProviderAliyunModule : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            context.Services.AddSingleton<ISmsSender, AliyunSmsSender>();
            Configure<AbpVirtualFileSystemOptions>(options =>
            {
                options.FileSets.AddEmbedded<AbpPhoneNumberLoginProviderAliyunModule>();
            });

            Configure<AbpLocalizationOptions>(options =>
            {
                options.Resources
                    .Add<PhoneNumberLoginProviderAliyunResource>("en")
                    .AddBaseTypes(typeof(AbpValidationResource))
                    .AddVirtualJson("EasyAbp/Abp/PhoneNumberLogin/Provider/Aliyun/Localization");
            });

            Configure<AbpExceptionLocalizationOptions>(options =>
            {
                options.MapCodeNamespace("EasyAbp.Abp.PhoneNumberLogin.Provider.Aliyun", typeof(PhoneNumberLoginProviderAliyunResource));
            });

            context.Services.Replace(ServiceDescriptor.Singleton<IPhoneNumberLoginVerificationCodeSender, AliyunPhoneNumberLoginVerificationCodeSender>());
        }
    }
}
